<template>
	<view class="setting">
		<u-navbar back-icon-color="#000" :back-text-style="{color: '#000'}" back-text="设置" />
		<view class="blockContainer">
			<view>
				关于
			</view>
			<u-cell-item title="云音乐新手指南" :arrow="false"></u-cell-item>
			<u-cell-item title="帮助与反馈" :arrow="false"></u-cell-item>
			<u-cell-item title="关于网易云音乐" :arrow="false"></u-cell-item>
		</view>
		<view @click="switchAccount" class="switchAccount jc-center ai-center">
			切换账号
		</view>
		<u-modal @confirm="confirmExist" show-cancel-button mask-close-able v-model="showModal" content="确定退出当前账号吗？"></u-modal>
	</view>
</template>

<script>
	import {
		logout
	} from '../../api/account.js'
	export default {
		data() {
			return {
				showModal: false
			};
		},
		methods: {
			switchAccount() {
				this.showModal = true
			},
			confirmExist() {
				logout().then(res => {
					if (res.code == 200) {
						uni.reLaunch({
							url: "/pages/login/index"
						})
					} else {
						uni.showToast({
							title: "退出失败",
							icon: "none"
						})
					}
				}).catch(err => [
					uni.showToast({
						title: "退出失败",
						icon: "none"
					})
				])
			}
		}
	}
</script>

<style lang="scss" scoped>
	.setting {
		position: relative;
		height: 100vh;

		.blockContainer {
			border-top: 7px solid #f4f4f4;
			padding: 0 6px;
			background-color: #FFFFFF;

			>view:first-child {
				padding: 10px 0px 0px 16px;
				color: #8b8b8b;
				font-size: 13px;
			}
		}

		.switchAccount {
			// border-top: 7px solid #f4f4f4;
			height: 48px;
			width: 100vw;
			color: $primary;
			background-color: #fff;
			font-size: 15px;
			position: absolute;
			bottom: 0;
		}
	}
</style>
